package ch1_Combination;
public class Combination {

	// num起辅助作用，值为k初始值，不变
	public static void combine(int n, int k, int low, int num, int[] array,
			int[] result) {
		if (k == 1) {
			for (int i = low; i <= n - k; i++) {
				result[num - k] = array[i];
				for (int j = 0; j < result.length; j++) {
					System.out.print(result[j]);
				}
				System.out.println("");
			}
		} else {
			for (int i = low; i <= n - k; i++) {
				result[num - k] = array[i];
				combine(n, k - 1, i + 1, num, array, result);
			}
		}

	}

	public static void main(String[] args) {
		int[] array = { 1, 2, 3, 4, 5 };
		int n = array.length;
		int k = 3;
		int[] result = new int[k];

		combine(n, k, 0, k, array, result);
	}
}